//
// Created by ct on 2020/10/28.
//

#ifndef NETTOP_CAP_MGR_H
#define NETTOP_CAP_MGR_H

#include <pcap.h>
#include <atomic>
#include "mt_list.h"
#include "packet_stats.h"

namespace nettop {
    struct packet_list : public mt_list<packet_stats> {
        std::atomic<size_t>	total_pkts;

        packet_list() : total_pkts(0) {
        }
    };

    class cap_mgr {


        pcap_t	*p_;
    public:
        cap_mgr(const cap_mgr&) = delete;
        cap_mgr& operator=(const cap_mgr&) = delete;

        cap_mgr();

        ~cap_mgr();

        void capture_dispatch(packet_list& p_list);

        void async_cap(packet_list& p_list, volatile bool& quit);
    };
}




#endif //NETTOP_CAP_MGR_H
